From d7dfed6f8090e16ac9978e98bb9940b58c947eff Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 24 Jan 2005 00:42:17 +0000 Subject: [PATCH] Add rest of Garmin name collision correction code to ensure names are unique when going to the unit. --- gpsbabel/garmin.c | 24 +++++++++++++++++------- gpsbabel/mkshort.c | 3 ++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 22c22df2d..723a57ce5 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -37,6 +37,8 @@ static char *poweroff = NULL; static char *snlen = NULL; static char *snwhiteopt = NULL; static char *deficon = NULL; +/* Technically, even this is a little loose as spaces arent allowed */ +static char valid_waypt_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"; static arglist_t garmin_args[] = { @@ -127,6 +129,11 @@ rw_init(const char *fname) break; } + if (global_opts.debug_level > 0) { + fprintf(stderr, "Waypoint type: %d\n" + "Chosen waypoint length %d\n", + gps_waypt_type, short_length); + } /* * If the user provided a short_length, override the calculated value. */ @@ -138,8 +145,7 @@ rw_init(const char *fname) if (snwhiteopt) setshort_whitespace_ok(mkshort_handle, atoi(snwhiteopt)); - /* Technically, even this is a little loose as spaces arent allowed */ - setshort_goodchars(mkshort_handle, "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"); + setshort_goodchars(mkshort_handle, valid_waypt_chars); setshort_mustupper(mkshort_handle, 1); } @@ -302,7 +308,7 @@ route_read(void) nroutepts = GPS_Command_Get_Route(portname, &array); - fprintf(stderr, "Routes %d\n", (int) nroutepts); +// fprintf(stderr, "Routes %d\n", (int) nroutepts); #if 1 for (i = 0; i < nroutepts; i++) { route_head *rte_head; @@ -433,15 +439,19 @@ waypoint_write(void) if(wpt->description) src = wpt->description; if(wpt->notes) src = wpt->notes; - ident = global_opts.synthesize_shortnames ? - mkshort(mkshort_handle, src) : - wpt->shortname; + /* + * mkshort will do collision detection and namespace + * cleaning + */ + ident = mkshort(mkshort_handle, + global_opts.synthesize_shortnames ? src : + wpt->shortname); /* Should not be a strcpy as 'ident' isn't really a C string, * but rather a garmin "fixed length" buffer that's padded * to the end with spaces. So this is NOT (strlen+1). */ -fprintf(stderr, "%s\n", ident); memcpy(way[i]->ident, ident, strlen(ident)); + if (global_opts.synthesize_shortnames) { xfree(ident); } diff --git a/gpsbabel/mkshort.c b/gpsbabel/mkshort.c index b4b16212b..48ab322d8 100644 --- a/gpsbabel/mkshort.c +++ b/gpsbabel/mkshort.c @@ -157,10 +157,12 @@ mkshort_del_handle(void *h) queue *e, *t; QUEUE_FOR_EACH(&hdr->namelist[i], e, t) { uniq_shortname *s = (uniq_shortname *) e; +#if 0 if (global_opts.verbose_status >= 2 && s->conflictctr) { fprintf(stderr, "%d Output name conflicts: '%s'\n", s->conflictctr, s->orig_shortname); } +#endif dequeue(e); xfree(s->orig_shortname); xfree(s); @@ -259,7 +261,6 @@ setshort_mustuniq(void *h, int i) hdl->must_uniq = i; } - char * #ifdef DEBUG_MEM MKSHORT(void *h, const char *istring, DEBUG_PARAMS ) -- 2.30.2